Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor: Use ScalarValue::from impl for strings #8429

Merged
merged 2 commits into from
Dec 6, 2023

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Dec 5, 2023

Which issue does this PR close?

Follow on to #8411

Rationale for this change

Inspired by the commentary on #8411 from @viirya and @Dandandan #8411 (comment) I took a walk through the code and found quite a few places where we could clean up the construction of ScalarValue::Utf8

What changes are included in this PR?

Use ScalarValue::from impl to create ScalarValue::Utf8 -- this both takes less code and may avoid some copies.

Are these changes tested?

Covered by existing tests

Are there any user-facing changes?

@alamb alamb changed the title Minor: Use ScalarValue::from impl for strings Minor: Use ScalarValue::from impl for strings Dec 5, 2023
@github-actions github-actions bot added sql SQL Planner logical-expr Logical plan and expressions physical-expr Physical Expressions optimizer Optimizer rules core Core DataFusion crate labels Dec 5, 2023
wrap_partition_value_in_dict(ScalarValue::Utf8(Some(
"26".to_owned(),
))),
wrap_partition_value_in_dict(ScalarValue::from("2021")),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks better and more concise to me. Hopefully by updating the code we'll also make the codebase easier to work with over time too

Comment on lines +479 to +480
max_value: Precision::Exact(ScalarValue::from("x")),
min_value: Precision::Exact(ScalarValue::from("a")),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is one case looking much concise.

@Dandandan Dandandan merged commit fd92bcb into apache:main Dec 6, 2023
22 checks passed
appletreeisyellow pushed a commit to appletreeisyellow/datafusion that referenced this pull request Dec 15, 2023
* Minor: Use ScalarValue::from impl for strings

* fix typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate logical-expr Logical plan and expressions optimizer Optimizer rules physical-expr Physical Expressions sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants